//
//  FindBlueViewController.m
//  project
//
//  Created by 圆圆陈 on 2017/12/15.
//  Copyright © 2017年 黄建华. All rights reserved.
//

#import "FindBlueViewController.h"
#import "BlueToothViewController.h"
#import "SNEquipmentViewController.h"
@interface FindBlueViewController ()

@end

@implementation FindBlueViewController
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
//    if (KK_BLEConnect.model.isConnected) { // 手环绑定界面
//        SNEquipmentViewController *equipVC = [[SNEquipmentViewController alloc]init];
//        [self.navigationController pushViewController:equipVC animated:NO];
//    }
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
//    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
//        self.navigationController.interactivePopGestureRecognizer.enabled = NO;
//    }
}

- (void)updateModel:(KKBLEModel *)model type:(KKBLEUpdateType)type {
    
    
    if (KK_BLEConnect.model.isConnected) { // 手环绑定界面
//        SNEquipmentViewController *equipVC = [[SNEquipmentViewController alloc]init];
//        [self.navigationController pushViewController:equipVC animated:NO];
        [self.navigationController popViewControllerAnimated:NO];
    }
}

- (void)viewDidLoad {
    [super viewDidLoad];
    UIImage     *backImage     = UIImageNamed(@"背景");
    UIImageView *backImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 20+FitSimpleIpx(0, 20), HHHWIDTH, HHHWIDTH*backImage.size.height/backImage.size.width)];
    backImageView.userInteractionEnabled = YES;
    backImageView.image                  = backImage;
    [self.view addSubview:backImageView];
    CGFloat height = 20+FitSimpleIpx(0, 20)+44+backImageView.bottom;
    UIView *backView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, HHHWIDTH*2/3, HHHHEIGHT/6)];
    backView.center             = CGPointMake(self.view.center.x, height+15);
    backView.layer.cornerRadius = 10;
    backView.clipsToBounds      = YES;
    backView.layer.borderColor  = SNCOLORGRAY.CGColor;
    backView.layer.borderWidth  = 1;
    [self.view addSubview:backView];
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, backView.width, backView.height*2/3)];
    if ([KK_BLELastDevice getObjectValue]) {
        label.text = HHH_Text(@"设备未连接");
    } else {
        label.text = HHH_Text(@"未绑定设备，请先绑定手环");
    }
    label.textAlignment = NSTextAlignmentCenter;
    label.numberOfLines = 0;
    label.font          = [UIFont systemFontOfSize:FitFont(17)];
    [backView addSubview:label];
    
    UILabel *line = [[UILabel alloc]initWithFrame:CGRectMake(0, backView.height*2/3, backView.width, 2)];
    line.backgroundColor = SNCOLORSEPRATE;
    [backView addSubview:line];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setTitleNormal:HHH_Text(@"扫描手环1")];
    [btn setTitleColorNormal:SNCOLORGRAY];
    btn.frame           = CGRectMake(0, backView.height*2/3+2, backView.width, backView.height/3-2);
    btn.titleLabel.font = [UIFont systemFontOfSize:FitFont(17)];
    [btn addTouchUpTarget:self action:@selector(pushToBlueVC)];
    [backView addSubview:btn];
}

- (void)pushToBlueVC {
    BlueToothViewController *blueVC = [[BlueToothViewController alloc]init];
    CustomTabBar            *tabBar = (CustomTabBar *)self.tabBarController;
    
    blueVC.type = 1;
    [tabBar hiddenTheTabBarView];
    [self.navigationController pushViewController:blueVC animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end

